(function(){"use strict";BX.namespace("BX.Landing.UI.Field");BX.Landing.UI.Field.DropdownPreview=function(i){this.items="items"in i&&i.items?i.items:{};BX.Landing.UI.Field.BaseField.apply(this,arguments);this.layout.classList.add("landing-ui-field-dropdown");this.layout.classList.add("landing-ui-field-dropdown-preview");this.frame=typeof i.frame==="object"?i.frame:null;this.format=typeof i.format==="function"?i.format:function(){};this.postfix=typeof i.postfix==="string"?i.postfix:"";this.property=typeof i.property==="string"?i.property:"";this.changeHandler=typeof i.onChange==="function"?i.onChange:function(){};this.elements=[];this.setValue(this.items[0].value,true);this.input.innerText=this.items[0].name;this.input.addEventListener("click",this.onInputClick.bind(this));this.onFrameLoad()};BX.Landing.UI.Field.DropdownPreview.CreateSelect=function(){return BX.create("select",{props:{className:"landing-ui-field-input landing-ui-field-dropdown"}})};BX.Landing.UI.Field.DropdownPreview.prototype={constructor:BX.Landing.UI.Field.DropdownPreview,__proto__:BX.Landing.UI.Field.BaseField.prototype,superClass:BX.Landing.UI.Field.BaseField,onInputClick:function(i){i.preventDefault();if(!this.popup){var t=this;var e=this.items.map(function(i){return{text:i.name,className:"landing-ui-field-dropdown-preview-item",menuShowDelay:0,subMenuOffsetX:10,items:[{text:'<div class="landing-ui-field-dropdown-preview-item-preview '+i.value+'">Text</div>',className:"landing-ui-field-dropdown-preview-item-child"}],onclick:function(){this.close();t.onChange(i)}}});this.popup=new BX.PopupMenuWindow({id:this.selector+this.property,bindElement:this.input,items:e,zIndex:9e3,angle:false,bindOptions:{forceBindPosition:true},events:{onPopupClose:function(){this.input.classList.remove("landing-ui-active")}.bind(this)}});this.input.parentNode.appendChild(this.popup.popupWindow.popupContainer)}this.input.classList.add("landing-ui-active");var n=BX.pos(this.input,this.input.parentNode);this.popup.popupWindow.popupContainer.style.top=n.bottom+"px";this.popup.popupWindow.popupContainer.style.left="0px";this.popup.popupWindow.popupContainer.style.right=""},onFrameLoad:function(){this.elements=[].slice.call(this.frame.document.querySelectorAll(this.selector));if(this.elements.length){this.items.some(function(i){if(this.elements[0].classList.contains(i.value)){this.setValue(i.value,true)}},this)}},onChange:function(i,t){this.setValue(i.value);this.input.innerText=i.name;if(!t){this.changeHandler(this.getValue(),this.items,this.postfix,this.property);BX.fireEvent(this.layout,"input")}},setValue:function(i){this.input.dataset.value=i},getValue:function(){return this.input.dataset.value}}})();
//# sourceMappingURL=dropdown_preview_field.map.js